﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace YahtzeeAspTest.Model
{
    public class Dice
    {
        private static Random rnd;
       
        public int Value { get; set; }
        public string ImageValue { get; set; }
        public bool Locked { get; set; }
        public Dice(int value = 1)
        {
            rnd = new Random();
            Locked = false;
            if (value > 0 && value < 7)
            {
                Value = value;
                ImageValue = "~/Dice" + value + ".png";
            }
            //else
            //{
            //    Value = 1;
            //    ImageValue  = "~/Dice" + value + ".png";
            //}
        }

        public void Roll()
        {
            if (!Locked)
            {
                int randomNumber = rnd.Next(1, 7);
                Value = randomNumber;
                ImageValue = "~/Dice" + randomNumber + ".png";
            }
            /*else
            {
                ImageValue = "~/DiceLocked" + this.Value +".png";
            }*/
          
        }
        public void lockADice()
        {
            Locked = Locked==true ? false : true;
            ImageValue = "~/DiceLocked" + this.Value + ".png";           
            //if (Locked == false) Locked = true;
            //else if (Locked == true) Locked = false;
            //TODO imagedice RED
        }
    }
}